home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / mod2tutb.zip / ARRAYS.MOD < prev    next >
Text File  |  1989-01-18  |  1KB  |  48 lines

  1.                                          (* Chapter 6 - Program 1 *)
  2. MODULE Arrays;
  3.  
  4. FROM InOut IMPORT WriteString, WriteCard, WriteLn;
  5.  
  6. VAR Index       : CARDINAL;
  7.     Automobiles : ARRAY [1..12] OF CARDINAL;
  8.  
  9. BEGIN   (* main program *)
  10.    FOR Index := 1 TO 12 DO
  11.       Automobiles[Index] := Index + 10;
  12.    END;
  13.    Automobiles[7] := 54;  (* example, change one value of array *)
  14.    WriteString("This is the first program with an array.");
  15.    WriteLn;
  16.    WriteLn;                       (* end of data initialization *)
  17.  
  18.    FOR Index := 1 TO 12 DO              (* display the data now *)
  19.       WriteString("Automobile number");
  20.       WriteCard(Index,3);
  21.       WriteString(" has the value of");
  22.       WriteCard(Automobiles[Index],3);
  23.       WriteLn;
  24.    END;
  25. END Arrays.
  26.  
  27.  
  28.  
  29.  
  30. (* Result of execution
  31.  
  32. This is the first example program with an array.
  33.  
  34. Automobile number  1 has the value of 11
  35. Automobile number  2 has the value of 12
  36. Automobile number  3 has the value of 13
  37. Automobile number  4 has the value of 14
  38. Automobile number  5 has the value of 15
  39. Automobile number  6 has the value of 16
  40. Automobile number  7 has the value of 54
  41. Automobile number  8 has the value of 18
  42. Automobile number  9 has the value of 19
  43. Automobile number 10 has the value of 20
  44. Automobile number 11 has the value of 21
  45. Automobile number 12 has the value of 22
  46.  
  47. *)
  48.